package cn.cnsuh.剑指offer.q57_和为s的连续正数序列;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Solution {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[][] continuousSequence = findContinuousSequence(n);
        for (int[] ints : continuousSequence) {
            for (int i = 0; i < ints.length; i++) {
                System.out.print(ints[i]);
            }
            System.out.println();
        }
    }

    static int[][] findContinuousSequence(int target) {
        int i = 1;
        int j = 1;
        int sum = 0;
        List<int[]> res = new ArrayList<>();

        while(i <= target/2){
            if(sum < target){
                sum+=j;
                j++;
            }else if(sum > target){
                sum-=i;
                i++;
            }else {
                int[] arr = new int[j-i];
                for(int k = i ; k < j ; k++ ){
                    arr[k-i] = k;
                }
                res.add(arr);
                sum-=i;
                i++;
            }
        }
        return res.toArray(new int[res.size()][]);
    }
}
